extension: add some Y' u8 fast paths
authorØyvind Kolås <pippin@gimp.org>
Wed, 4 Apr 2018 21:49:55 +0000 (23:49 +0200)
committerØyvind Kolås <pippin@gimp.org>
Wed, 4 Apr 2018 21:49:55 +0000 (23:49 +0200)
GIMP makes use of "Y' u8" to "R'G'B' u8" and we had no paths covering it,
making it go through floating point. This commit adds code paths for expanding
single grayscale u8 to R'G'B and R'G'B'A as well as R'aG'aB'aA u8.

extensions/gggl.c

index 625d7302410d5092d0125d9234d0a4d5a57edd25..8195ba1d1d14cf93c6b938947f1e88da7a8a7220 100644 (file)
@@ -484,6 +484,37 @@ conv_gF_rgbF (const Babl *conversion,unsigned char *src, unsigned char *dst, lon
     }
 }
 
+static void
+conv_g8_rgb8 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
+{
+  long n = samples;
+
+  while (n--)
+    {
+      dst[0]=*src;
+      dst[1]=*src;
+      dst[2]=*src;
+      dst += 3;
+      src += 1;
+    }
+}
+#define conv_g8_rgbA8  conv_g8_rgba8
+static void
+conv_g8_rgba8 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
+{
+  long n = samples;
+
+  while (n--)
+    {
+      dst[0]=*src;
+      dst[1]=*src;
+      dst[2]=*src;
+      dst[3]=255;
+      dst += 4;
+      src += 1;
+    }
+}
+
 static void
 conv_gaF_rgbaF (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
 {
@@ -1067,6 +1098,9 @@ init (void)
   o (ga8, gaF);
   o (gA8, gAF);
   o (g8, gF);
+  o (g8, rgb8);
+  o (g8, rgba8);
+  o (g8, rgbA8);
   o (gaF, ga16);
   o (gAF, gA16);
   o (gF, g16);